<?php
    class product_index_controller extends controllerBase
    {
        public function process()
        {
            if(isset($_POST['val']))
            {
                $aVals = $_POST['val'];
                if(isset($aVals['id']) && count($aVals['id']))
                {
                    foreach($aVals['id'] as $iProductId)
                    {
                        if($iProductId)
                        {
                            $this->database->delete('product','product_id = '.(int)$iProductId);
                        }
                    }
                    return $this->url->getLink('admin/product',true,'Delete products successful.');
                }
            }
            $aProducts = $this->database->getListObject('SELECT p.*,c.title AS category_name,images.url AS image_url  FROM product AS p JOIN category AS c ON p.category_id = c.category_id LEFT JOIN images ON p.image_id = images.image_id');
            $this->set(array('aProducts' => $aProducts));
        }
    }
?>
